<template>
	<view>
		<view class="" v-for="(item, index) in MyAdviceList" :key="index">
			<uni-card  type="line" :title="item.adviceTitle" :extra="item.adviceTime" :thumbnail="imageList(item.advicePhoto)">
				<mp-html class="notice-content content" :content="item.adviceContent" />
					<view class="chahui">
				<text style="color: blue; margin-right: 20rpx;" @click="showAdvice(item)">查看</text>
				<view class="" v-show="item.replyStatus==0">
					<text style="color: blue; margin-right: 8px;" @click="goUploadAdvice(item)">修改</text>
					<text style="color: red;" @click="recal(item.adviceId)">撤回</text>
				</view>
				<view v-show="item.replyStatus==1">
					<text style="color: red;" @click="yesReply(item.replyContent)">已回复</text>
				</view>
			</view>
			</uni-card>
		</view>
	</view>
</template>

<script>
	import { RecalMyAdvice } from "@/api/home/home.js"
	export default {
		name: "my-advice",
		props:{
			MyAdviceList: {
			      type: Array,
			      default: () => []
			    },
		},
		data() {
			return {
				s:[]
			};
		},
		methods:{
		noReply(){
			this.$showTip('耐心等待回复!!')
		},
		yesReply(msg){
			uni.showModal({
			     content: msg,
				 showCancel: false,
			    success: function (res) {
			        if (res.confirm) {
			            // console.log('用户点击确定');
			        }else if (res.cancel){
			           // console.log('用户点击取消');
			        }
			    }
			});
		},
			showAdvice(event){
				uni.navigateTo({
					url: '/pages/adviceDetails/adviceDetails?item='+encodeURIComponent(JSON.stringify(event))
				})
			},
		recal(adviceId){
			uni.showModal({
				title: '提示',
				content: '是否撤回当前信息',
				success: (res) => {
					if (res.confirm) {
						RecalMyAdvice(adviceId).then(res=>{
							if(res.code==200){
							  this.$showTip(res.msg,'success')
							}
						}) 
						this.$router.go(0)

					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
	   },
	   goUploadAdvice(item){
			 console.log("啥" + JSON.stringify(item.adviceId))  
		uni.navigateTo({
			   url:'/pages/upload-active/upload-active?adviceId=' + item.adviceId + '&adviceTitle=' +  item.adviceTitle + '&adviceContent=' + item.adviceContent + '&advicePhoto=' +item.advicePhoto+ '&acceptPartyId=' +item.acceptPartyId
		})
	   },
		},
		computed: {
	imageList() {
		return function(e) {
			if(e==null){
				return '@/static/images/head.jpg'
			}
			return e.split(",")[0]
		}
	},
		},
		onShow() {
		}
	}
</script>

<style>
	.chahui {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}

	.content {
		overflow: hidden;
		-webkit-line-clamp: 2;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}
</style>
